<script>
/**
 * 盒子
 *  */
import {
    defineComponent,
    ref,
    getCurrentInstance,
    reactive,
    toRef,
    computed,
    onMounted,
    onActivated,
    watch,
} from 'vue';
import mei from '@/assets/images/mei.png';
import tan from '@/assets/images/tan.png';
import tree from '@/assets/images/tree.png';
export default defineComponent({
    props: {
        dataInfo: {
            type: Array,
            default: () => {
                return []
            },
        },
    },
    setup(props) {
        const dataContainer = reactive({
            loading: false,
            list:[
                    { company: '吨', numbers: '', center: '等效节约标准煤', icons: mei },
                    { company: '吨', numbers: '', center: '等效节约二氧化碳', icons: tan },
                    { company: '棵', numbers: '', center: '等效植树', icons: tree },

                ]
        });
        watch(
            () => props.dataInfo,
            (newDataInfo) => {
                console.log(newDataInfo)
                // const val=JSON.parse(JSON.stringify(newDataInfo))
                dataContainer.list.forEach((v,i)=>{
                        v.numbers=newDataInfo[i]?.toFixed(0)
                      
                })
            },
            {
                immediate: true,
                deep: true,
            },
        )

        onMounted(() => {

        });
        return {
            dataContainer,

        };
    },
});
</script>

<template>
    <div class="right_3">
        <div class="items" v-for="(item, index) in dataContainer.list">
            <img :src="item.icons" alt="">
            <p class="psone">{{ item.center }}</p>
            <p class="pstwo">
                <span> {{ item.numbers>=10000?(item.numbers/10000).toFixed(2):item.numbers }} </span>
                <span class="company">&nbsp;{{ item.numbers>=10000?'万'+item.company:item.company}}</span>
            </p>
        </div>
    </div>
</template>

<style lang="scss" scoped>
.right_3 {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-around;
    color: #F3FFFE;
    padding: 1.875rem 0.000rem;
    .items {
        text-align: center;
        img{
            width: 5.250rem;
            height: 4.250rem;
        }
        .psone{
            font-size: 0.875rem;
            margin-top: 0.625rem;
        }
        .pstwo{
            font-size: 1.500rem;
            margin-top: 0.313rem;
            .company{
                font-size: 0.875rem;
            }
        }
    }
}
</style>
